<template>
  <div :id='pid'></div>
</template>

<script>
export default {
  name: 'bdmap',
  props:['pid','location'],
  data() {
    return {}
  },
  mounted() {
    this.init()
  },
  methods: {
    init(){
      try {
        var map = new BMapGL.Map(this.pid);
        map.centerAndZoom(new BMapGL.Point(116.331398,39.897445), 12);
        var myGeo = new BMapGL.Geocoder();
        myGeo.getPoint(this.location, function(point){
          if(point){
            map.centerAndZoom(point, 16);
            // map.addOverlay(new BMapGL.Marker(point, {title: this.location}))
          }else{
            alert('您选择的地址没有解析到结果！');
          }
        }, this.location)
      }catch (e) {

      }
    }
  }
}
</script>

<style scoped>
div{
  width: 100%;
  height: 180px;
}
</style>
